package com.iotproject.studyservice.service.impl;

import com.alibaba.excel.EasyExcel;
import com.iotproject.studyservice.entity.StudyListeningType;
import com.iotproject.studyservice.entity.excel.StudyListeningTypeData;
import com.iotproject.studyservice.listener.StudyListeningTypeExcelListener;
import com.iotproject.studyservice.mapper.StudyListeningTypeMapper;
import com.iotproject.studyservice.service.StudyListeningTypeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import java.io.InputStream;

/**
 * <p>
 * 听力类别 服务实现类
 * </p>
 *
 * @author testjava
 * @since 2023-04-07
 */
@Service
public class StudyListeningTypeServiceImpl extends ServiceImpl<StudyListeningTypeMapper, StudyListeningType> implements StudyListeningTypeService {

    @Override
    public void importStudyListeningTypeData(MultipartFile file, StudyListeningTypeService studyListeningTypeService) {
        try {
            //读取Excel 表数据
            InputStream fileStream = file.getInputStream();
            EasyExcel.read(fileStream, StudyListeningTypeData.class, new StudyListeningTypeExcelListener(studyListeningTypeService)).sheet().doRead();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
